package com.teaphy.coroutinecrawler.flow.operators

import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.buffer
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.collectIndexed
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.runBlocking

fun main() = runBlocking{
    flow {
        for (value in 0..3) {
            emit(value)
            delay(100)
        }
    }.collectIndexed { index, value ->
        println("接收到的元素：$value, 索引：$index")
    }
}